package com.itmg.admin.action;

import java.util.List;

import com.itmg.admin.business.service.AdminService;
import com.itmg.dao.model.KeywordsModel;
import com.itmg.dao.model.TopImageModel;
import com.itmg.factory.ServiceFactory;
import com.opensymphony.xwork2.ActionSupport;
public class AdminAction extends ActionSupport{

	private static final long serialVersionUID = 1L;
	private AdminService adminService = ServiceFactory.getAdminService();
	
	private TopImageModel model;
	private List<TopImageModel> topImageModelList;
	private List<KeywordsModel> topKeywordsList;
	private Integer isindex;
	private String message;
	
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public TopImageModel getModel() {
		return model;
	}
	public void setModel(TopImageModel model) {
		this.model = model;
	}
	public AdminService getAdminService() {
		return adminService;
	}
	public void setAdminService(AdminService adminService) {
		this.adminService = adminService;
	}
	public List<TopImageModel> getTopImageModelList() {
		return topImageModelList;
	}
	public void setTopImageModelList(List<TopImageModel> topImageModelList) {
		this.topImageModelList = topImageModelList;
	}
	public List<KeywordsModel> getTopKeywordsList() {
		return topKeywordsList;
	}
	public void setTopKeywordsList(List<KeywordsModel> topKeywordsList) {
		this.topKeywordsList = topKeywordsList;
	}
	public Integer getIsindex() {
		return isindex;
	}
	public void setIsindex(Integer isindex) {
		this.isindex = isindex;
	}
	
	//添加topImage
	public String addTopImage(){
		try {
			adminService.save(model);
		} catch (Exception e) {
			e.printStackTrace();
			message = "ADD FAILURE!";
			return INPUT;
		}
		message = "ADD SUCCESS!";
		model = null;
		return SUCCESS;
	}
	
	//得到首页要显示的info
	public String getTopInfo(){
		try {
			topImageModelList = adminService.getTopImage() ;
			topKeywordsList = adminService.getTopKeyword();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
	
	//修改image
	public String updateImage(){
		return SUCCESS;
	}
	
	//查询所有的Image
	public String getAllImage(){
	    return SUCCESS;
	}
	
	//删除Image
	public String deleteImage(){
	    return SUCCESS;
	}
}
